import axios from "@/libs/api.request";
import { setLocal, getLocal, delLocal } from '@/utils/storage'
// ---------------------------------- 微信相关 ---------------------------------- 

// 获取微信openId
export const getOpenId = params => {
  return axios.request({
    url: "/carStation/api/users/getOpenId.do",
    data: params,
    method: "post"
  });
};

// 用户是否关注公众号
export const judgeIsFollow = params => {
  return axios.request({
    url: "/carStation/api/users/judgeIsFollow.do",
    data: params,
    method: "post"
  });
};


// ---------------------------------- 用户相关信息 ---------------------------------- 
// 注册用户信息
export const PostRegisterUsers = params => {
  return axios.request({
    url: "/carStation/api/users/registerUsers.do",
    data: params,
    method: "post"
  });
};

// 查询用户信息
export const PostCarUsers = params => {
  return axios.request({
    url: "/carStation/api/users/queryUsers.do",
    data: params,
    method: "post"
  });
};

//兑换贵宾卡接口
export const addUserCoupon = params => {
  return axios.request({
    url: "/carStation/api/userCoupon/addUserCoupon.do",
    data: params,
    method: "post"
  });
}; 
//获取贵宾卡列表
export const queryUserCouponList = params => {
  return axios.request({
    url: "/carStation/api/userCoupon/queryUserCouponList.do",
    data: params,
    method: "post"
  });
};
// 更新用户信息
export const updateUsers = params => {
  return axios.request({
    url: "/carStation/api/users/updateUsers.do",
    data: params,
    method: "post"
  });
};
// ---------------------------------- 评论 ----------------------------------
//服务评价
export const addComment = params => {
  return axios.request({
    url: "/carStation/api/order/addComment.do",
    data: params,
    method: "post",
    headers: {
      "content-type": "multer/form-data"
    }
  });
};
// ---------------------------------- 发票 ----------------------------------
export const inxoiceAddInxoice = params => {
  return axios.request({
    url: "/carStation/api/inxoice/addInxoice.do",
    data: params,
    method: "post",
  });
};
// ---------------------------------- 问卷 ----------------------------------
export const addUserQuestionnaire = params => {
  return axios.request({
    url: "/carStation/api/userQuestionnaire/addUserQuestionnaire.do",
    data: params,
    method: "post",
    /* headers: {
      'Content-Type': 'application/json;charset=utf-8'
    } */
  });
};
// ---------------------------------- 车辆管理 ---------------------------------- 

// 查询车辆信息
export const PostCarInfo = params => {
  return axios.request({
    url: "/carStation/api/cars/queryCars.do",
    data:  {
      ...params,
      openId:getLocal('openid')
    },
    method: "post"
  });
};


// 数据字典 
export const dataDir = params => {
  return axios.request({
    url: "/carStation/api/dataDir.do",
    data: params,
    method: "post"
  });
};

// 添加车辆信息
export const addCars = params => {
  return axios.request({
    url: "/carStation/api/cars/addCars.do",
    data: params,
    method: "post"
  });
};


// 修改车辆信息
export const updateCars = params => {
  return axios.request({
    url: "/carStation/api/cars/updateCars.do",
    data: params,
    method: "post"
  });
};

// 删除车辆信息
export const delCars = params => {
  return axios.request({
    url: "/carStation/api/cars/delCars.do",
    data: params,
    method: "post"
  });
};

// 行驶证识别
export const readCarInfo = params => {
  return axios.request({
    url: "/carStation/api/cars/readCarInfo.do",
    data: params,
    method: "post",
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

// 上传文件 附件
export const getWxJsConfig = params => {
  return axios.request({
    url: "/carStation/app/common/sigleFileUpload.do",
    data: params,
    method: "post",
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

// ---------------------------------- 车检数据 ---------------------------------- 

// 预约时间段查询
export const queryCarTime = params => {
  return axios.request({
    url: "/carStation/api/order/queryCarTime.do",
    data: params,
    method: "post"
  });
};

// 车检数据提交
export const createOrder = params => {
  return axios.request({
    url: "/carStation/api/order/createOrder.do",
    data: params,
    method: "post"
  });
};

// 车检数据查询
export const queryOrder = params => {
  return axios.request({
    url: "/carStation/api/order/queryOrder.do",
    data: {
      ...params,
      openId:getLocal('openid')
    },
    method: "post"
  });
};

// 车检进度查询
export const queryOrderStep = params => {
  return axios.request({
    url: "/carStation/api/order/queryOrderStep.do",
    data: params,
    method: "post"
  });
};

// 支付接口
export const wxPayBefore = params => {
  return axios.request({
    url: "/carStation/api/order/wxPayBefore.do",
    data: params,
    method: "post"
  });
};

// 发送短信验证码
export const sendVerifyCode = params => {
  return axios.request({
    url: "/carStation/api/users/sendVerifyCode.do",
    data: params,
    method: "post"
  });
};

// 电子单据
export const createPDF = params => {
  return axios.request({
    url: "/carStation/api/order/createPDF.do",
    data: params,
    method: "post"
  });
};
//修改订单办理人
export const updateOrderUserName = params => {
  return axios.request({
    url:'/carStation/api/order/updateOrderUserName.do',
    data:params,
    method:"post"
  })
}
//申请退费
export const createOrderRefund = params => {
  return axios.request({
    url:'/carStation/api/orderRefund/createOrderRefund.do',
    data:params,
    method:"post"
  })
}
//删除订单
export const deleteCarOrder = params => {
  return axios.request({
    url:'/carStation/api/order/deleteCarOrder.do',
    data:params,
    method:"post"
  })
}
//综检
export const createInspectionOrder = params => {
  return axios.request({
    url:'/carStation/api/order/createInspectionOrder.do',
    data:params,
    method:"post"
  })
}